
import { message } from "antd";
import { IOptions, ServerError } from "@/serve";

/**
 * 显示错误信息
 * @param error 
 * @param options 
 */
export function showError(error: unknown, options?: IOptions) {
    if (options?.isShowError !== false) {
        if (error instanceof ServerError) {
            const content = error.message || '请求错误'
            message.error({ content, key: content });
        } else if (error instanceof Error) {
            const content = error.message || '请求错误'
            message.error({ content, key: content });
        } else {
            const content = '请求错误'
            message.error({ content, key: content });
        }
    }
    return error;
}